package com.hxkcloud.nurse.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hxkcloud.nurse.R;
import com.hxkcloud.nurse.utils.StringUtil;

/**
 * Created by william_sun on 2016-07-07.
 * Description:患者信息的历史记录
 */
public class HistoryRecordActivity extends BaseActivity implements View.OnClickListener {
    //title
    private LinearLayout ll_title;
    private ImageView iv_back;
    private TextView tv_title;

    private LinearLayout ll_symptom;
    private LinearLayout ll_basicinfo;
    private LinearLayout ll_oldhistory;
    private View view_line1;
    private View view_line2;

    private final int historytype_symptom = 0;
    private final int historytype_basicinfo = 1;
    private final int historytype_oldhistory = 2;

    private String patientId;
    private boolean isChanke = false;

    @Override
    protected void updateByHandler(Message msg) {
        switch (msg.what) {

        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_historyrecord);

        patientId = this.getIntent().getStringExtra("patientId");
        isChanke = this.getIntent().getBooleanExtra("isChanke", false);

        initView();
        initListener();
    }

    @Override
    protected void initView() {
        ll_title = (LinearLayout) findViewById(R.id.ll_title);
        iv_back = (ImageView) findViewById(R.id.iv_title_back);
        tv_title = (TextView) findViewById(R.id.tv_title_title);

        ll_symptom = (LinearLayout) findViewById(R.id.ll_historyrecord_symptom);
        ll_basicinfo = (LinearLayout) findViewById(R.id.ll_historyrecord_basicinfo);
        ll_oldhistory = (LinearLayout) findViewById(R.id.ll_historyrecord_oldhistory);
        view_line1 = findViewById(R.id.view_historyrecord_line1);
        view_line2 = findViewById(R.id.view_historyrecord_line2);

        setTitlePadding(ll_title);
        iv_back.setVisibility(View.VISIBLE);
        tv_title.setText(getResources().getText(R.string.historyrecord));

        if (isChanke) {
            ll_symptom.setVisibility(View.GONE);
            ll_oldhistory.setVisibility(View.GONE);
            view_line1.setVisibility(View.GONE);
            view_line2.setVisibility(View.GONE);
        }
    }

    @Override
    protected void initListener() {
        iv_back.setOnClickListener(this);
        ll_symptom.setOnClickListener(this);
        ll_basicinfo.setOnClickListener(this);
        ll_oldhistory.setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_title_back:
                finish();
                break;
            case R.id.ll_historyrecord_symptom:
                StringUtil.zhugeTrack(mContext, "管理-患者信息-历史记录-症状/诊疗", "历史记录症状/诊疗查看数");

                Intent iSymptom = new Intent(mContext, SymptomRecordActivity.class);
                iSymptom.putExtra("title","症状/诊疗记录");
                iSymptom.putExtra("type", historytype_symptom);
                iSymptom.putExtra("patientId", patientId);
                startActivity(iSymptom);
                break;
            case R.id.ll_historyrecord_basicinfo:
                StringUtil.zhugeTrack(mContext, "管理-患者信息-历史记录-基本信息", "历史记录基本信息查看数");

                Intent iBasicinfo = new Intent(mContext, SymptomRecordActivity.class);
                iBasicinfo.putExtra("title","基本信息");
                iBasicinfo.putExtra("type", historytype_basicinfo);
                iBasicinfo.putExtra("patientId", patientId);
                startActivity(iBasicinfo);
                break;
            case R.id.ll_historyrecord_oldhistory:
                StringUtil.zhugeTrack(mContext, "管理-患者信息-历史记录-既往史", "历史记录既往史查看数");

                Intent iOldhistory = new Intent(mContext, SymptomRecordActivity.class);
                iOldhistory.putExtra("title","既往史");
                iOldhistory.putExtra("type", historytype_oldhistory);
                iOldhistory.putExtra("patientId", patientId);
                startActivity(iOldhistory);
                break;
        }
    }
}
